<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>Title</title>
        <link href="https://cdn.bootcss.com/twitter-bootstrap/3.0.1/css/bootstrap.min.css" rel="stylesheet">
    </head>
    <body>


        <div class="container">
            <div class="row clearfix">
                <div class="col-md-12 column">
                    <form id="form" action="/prefund/list" method="post">
                    <h1 class="text-center">
                        客户预存款管理
                    </h1>
                    <h3 class="text-right text-success">
                        欢迎您:管理员
                        <#--<@shiro.principal property="name" />-->
                    </h3>


                        <div class="form-group">
                            <div class="col-sm-2">
                                <button type="button" class="btn btn-default btn-block"
                                        value="" style="background-color: cornflowerblue;font-size: large"
                                >筛选查询</button>
                            </div>
                        </div>

                    <div class="col-sm-offset-11 col-sm-0">
                        <button type="submit" class="btn btn-success"
                                <#--onclick="accountSubmit()"-->
                        style="margin-bottom: 10px">查询</button>
                    </div>
                    <div class="col-md-4 column">
                        <label for="type" class="col-sm-2 control-label">客户类型</label>
                        <div class="col-sm-10">
                            <select name="tid" class="form-control" id="type">
                                <option value="0">请选择菜单</option>
                                <#if clientTypeList?exists>
                                    <#list clientTypeList as type>
                                        <option value="${type.tid?if_exists}"
                                            <#if  (form.tid??)>
                                                <#if form.tid==type.tid>selected</#if>
                                            </#if>

                                        >${type.typeName}</option>
                                    <#--<option value="${model.id?if_exists}" <#if menu.parentId== model.id>selected</#if>>${model.name}</option>-->
                                    </#list>
                                </#if>
                            </select>
                        </div>
                    </div>
                        <div class="col-md-4 column">
                        <label for="name" class="col-sm-2 control-label">客户名称</label>
                        <div class="col-sm-10">
                            <select id="name" name="nid" class="form-control">
                                <option value="-1">请选择</option>
                                <#if nameList?exists>
                                    <#list nameList as name>
                                        <option value="${name.nid?if_exists}"
                                                <#if  (form.nid??)>
                                                    <#if name.nid==form.nid>selected</#if>
                                                </#if>

                                        >${name.name}</option>
                                    <#--<option value="${model.id?if_exists}" <#if menu.parentId== model.id>selected</#if>>${model.name}</option>-->
                                    </#list>
                                </#if>
                            </select>
                        </div>
                    </div>




                    <div class="col-md-4 column">
                        <label for="balanceState" class="col-sm-2 control-label">余额状态</label>
                        <div class="col-sm-10">
                            <select name="balanceState" class="form-control" id="balanceState">
                                <option
                                        <#if  (form.balanceState??)>
                                            <#if form.balanceState=="全部">selected</#if>
                                        </#if>
                                >全部
                                </option>
                                <option
                                    <#if  (form.balanceState??)>
                                        <#if form.balanceState=="有余额">selected</#if>
                                    </#if>
                                    >有余额
                                </option>
                                <option
                                    <#if  (form.balanceState??)>
                                        <#if form.balanceState=="余额为零">selected</#if>
                                    </#if>
                                    >余额为零
                                </option>

                            </select>
                        </div>
                    </div>

                    </form>

                </div>
            </div>
        </div>


        <div class="container">
            <div class="row clearfix">
                <div class="col-md-12 column">

                    <div class="form-group">
                        <div class="col-sm-2">
                            <button type="button" class="btn btn-default btn-block"
                                    value="" style="background-color: cornflowerblue;font-size: large"
                            >数据列表</button>
                        </div>
                    </div>

        <div class="col-sm-offset-10 col-sm-0">
            <button type="submit" class="btn btn-success"
                    onclick="location.href='/prefund/order/add-ui'"
                    style="margin-bottom: 10px">新增</button>
            <button type="submit" class="btn btn-success"
                    <#--onclick="accountSubmit()"-->
                    style="margin-bottom: 10px">导出</button>
        </div>
        <table class="table">
            <thead>
            <tr>
                <th>客户名称</th>
                <th>可用余额</th>
                <th>联系人</th>
                <th>客户电话</th>
                <th>操作</th>
            </tr>
            </thead>
            <tbody>
            <#--                    c:forEach items='${pageInfo.list}'  var='trip'-->
            <#list pageInfo.list as prefund>
                <tr class="info">
                    <td>${prefund.clientName!}</td>
                    <td>${prefund.usedBalance?c}</td>
                    <td>${prefund.contact!}</td>
                    <td>${prefund.clientPhone!}</td>
                    <td>

                        <button type="button" class="btn btn-info btn-link"
                                onclick="location.href='/prefund/order/list?pid=${prefund.pid}'">预存款使用记录</button>

                    </td>
                </tr>
            </#list>

            </tbody>
        </table>
        <ul class="pagination" style="float: right">


            <#if pageInfo.hasPreviousPage >
                <li>
                    <a href="javascript:;" onclick="location.href='/account/list?index=1'">首页</a>
                </li>

                <li>
                    <a href="javascript:;" onclick="location.href='/account/list?index=${pageInfo.prePage}'">上一页</a>
                </li>
            </#if>


            <#if pageInfo.pageNum lt pageInfo.pages >
                <li>
                    <a href="javascript:;" onclick="location.href='/account/list?index=${pageInfo.nextPage}'">下一页</a>
                </li>
                <li>
                    <a href="javascript:;" onclick="location.href='/account/list?index=${pageInfo.pages}'">尾页</a>
                </li>
            </#if>
        </ul>

                </div>
            </div>
        </div>


        <script src="/static/js/jquery-1.8.0.min.js" ></script>
        <script>
            // 客户类型、名称二级联动
            $("#type").change(function () {
                //1.获得被选中的value值
                var tid= $(this).val();
                if(tid==0){
                    $("#name")[0].length=0;//让下拉框的长度为0
                    $("#name")[0].add(new Option("请选择菜单",-1));//Option(显示到标签对中的值,value值)
                    alert("请选择客户类型！");
                    return;
                }else{
                    //将deptId的值传给服务器，服务器进行查询
                    $.ajax({
                        url:"/name/getNames",
                        data:"tid="+tid,
                        type:"post",
                        dataType:"json",
                        success:function(rs){//rs用来接受返回的结果
                            $("#name")[0].length=0;//让下拉框的长度为0
                            for(var i=0;i<rs.length;i++){
                                $("#name")[0].add(new Option(rs[i].name,rs[i].nid));//Option(显示到标签对中的值,value值)
                            }
                        }
                    })
                }

            });

            // // 删除账目信息
            // function deleteOne(aid,obj){
            //     if (confirm("您确定删除该条账目信息吗？")) {
            //         //发送ajax请求到后台,并传递全部的参数.
            //         $.getJSON(
            //             "/account/delete?aid=" + aid,
            //             null,
            //             function (result) {
            //                 if (result.code == 0) {
            //                     $(obj).parent().parent().remove();
            //                 }else {
            //                     alert(result.msg)
            //                 }
            //             }
            //         );
            //     }
            // }
            //
            // //审核账目信息
            // function checkState(aid) {
            //     //发送ajax请求到后台,并传递全部的参数.
            //     $.getJSON(
            //         "/account/check?aid=" + aid,
            //         null,
            //         function (result) {
            //             if (result.code == 0) {
            //                 alert(result.msg)
            //                 location.href = "/account/list";
            //             }else {
            //                 alert(result.msg)
            //             }
            //         }
            //     );
            // }
            //
            // //确认账目信息
            // function tradeState(aid) {
            //     //发送ajax请求到后台,并传递全部的参数.
            //     $.getJSON(
            //         "/account/affirm?aid=" + aid,
            //         null,
            //         function (result) {
            //             if (result.code == 0) {
            //                 alert(result.msg)
            //                 location.href = "/account/list";
            //             }else {
            //                 alert(result.msg)
            //             }
            //         }
            //     );
            // }
        </script>
    </body>
</html>